﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VNPT.Utility
{
    public partial class fInputBox : DevExpress.XtraEditors.XtraForm
    {
        public fInputBox()
        {
            InitializeComponent();
            this.Shown += (a, e) =>
            {
                this.txtText.Text = txt;
                this.txtText.Focus();
                this.txtText.SelectAll();
            };
        }
        string txt = "";
        public fInputBox(string Text)
            : this()
        {
            txt = Text;
        }

        public string ShowMe()
        {
            this.ShowDialog();
            return this.txtText.Text;
        }

        private void btnChapNhan_Click(object sender, EventArgs e)
        {
            this.Dong = true;
            if (string.IsNullOrWhiteSpace(this.txtText.Text))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Chưa có dữ liệu!","Xác nhận!",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Dong = false;
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Dong = true;
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
        bool Dong = true;
        private void fInputBox_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = !Dong;
        }
    }
}
